package com.otitan.la.forest.system.controller;

import com.otitan.la.forest.system.dto.UserRoleDTO;
import com.otitan.la.forest.system.service.UserRoleService;
import com.otitan.webapp.framework.basepro.model.DataResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 用户角色 Controller
 *
 * @author jiacs
 * @email xxx
 * @date 2020-09-15 10:34:19
 */
@Slf4j
@Api(tags = "用户角色关系API")
@RestController
@RequestMapping("/user/role")
public class UserRoleController {

    @Autowired
    private UserRoleService userRoleService;


    @ApiOperation(value = "新增")
    @PostMapping()
    public DataResult add(@Valid @RequestBody UserRoleDTO dto, BindingResult bindingResult) {
        return userRoleService.add(dto, bindingResult);
    }

    @ApiOperation(value = "批量删除")
    @DeleteMapping("/batchDelete")
    public DataResult batchDelete(@Valid @RequestBody UserRoleDTO dto, BindingResult bindingResult) {
        return userRoleService.batchDelete(dto, bindingResult);
    }

}
